/**
 * 
 */
package com.kandinfo.survey.common.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kandinfo.base.common.constant.ResultCode;
import com.kandinfo.base.common.dto.ResultDto;
import com.kandinfo.base.common.dto.ResultDtoFactory;
import com.kandinfo.survey.common.dto.QuestionDto;
import com.kandinfo.survey.common.service.QuestionService;

/**
 * @author tangqh
 *
 */
@Controller
@RequestMapping(value = "/question")
public class QuestionController {
    
    @Autowired
    QuestionService questionService;
    
	/**
	 * 题目管理入口
	 */
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public String list(Model model) {
		return "views/question/question-list";
	}
	/**
	 * 题目详细信息入口
	 */
	@RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
	public String detail(Model model, @PathVariable Long id) {
		return "views/question/question-detail";
	}

	/**
	 * 通过ID或ID List获取数据
	 */
	@RequestMapping(value = "/get", method = RequestMethod.GET)
	public ResultDto get(Model model, @RequestParam("id")Long id, @RequestParam("idList[]")List<Long> idList) {
		return ResultDtoFactory.createResult(ResultCode.SUCCESS, "查询成功", null);
	}
	
	/**
     * 新建题目
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto save(@RequestParam QuestionDto questionDto) {
        return questionService.newQuestion(questionDto);
    }

}
